//vuex
import  Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)


export default new Vuex.Store({
	state:{
		token:'',
		user:{}
	},
	mutations:{
		getToken(state,value){
			if(value){
				state.token=value
				uni.setStorageSync("token", JSON.stringify(value));
			}else{
				if(uni.getStorageSync('tokenCode')){
					state.tokenCode = JSON.parse(uni.getStorageSync('tokenCode'))
				}
			}
		},
		getUserInfo(state,value){
			if(value){
				state.user=value
				uni.setStorageSync("user", JSON.stringify(value));
			}else{
				if(uni.getStorageSync('user')){
					state.user = JSON.parse(uni.getStorageSync('user'))
				}
			}
		}
		
	}
})